<template>
  <div class="project-show-box basic-from">
    <v-dialog title="查看" :show.sync="dialogVisible" width="1200px" @beforeClose="beforeClose" :close-on-click-modal="false">
      <div class="card-title">工程信息</div>
      <el-form ref="editForm" :model="showForm" class="form-wrap" size="small" label-position="top">
        <el-form-item label="工程名称" prop="projectName">
          <span class="int-text">{{showForm.projectName}}</span>
        </el-form-item>
        <el-form-item label="工程地址" prop="projectAddress">
          <span class="int-text">{{showForm.projectAddress}}</span>
        </el-form-item>
        <el-form-item label="工程类型" prop="projectType">
          <span class="int-text">{{getCardTypeValue(showForm.projectType,projectTypes)}}</span>
        </el-form-item>
        <el-form-item label="建设内容" class="full" prop="projectContent">
          <span class="int-text">{{showForm.projectContent}}</span>
        </el-form-item>
        <el-form-item label="建设规模" class="full" prop="projectScale">
          <span class="int-text">{{showForm.projectScale}}</span>
        </el-form-item>
        <el-form-item label="工程建设工期" prop="projectStart">
          <span class="int-text">{{showForm.projectStart}}-{{showForm.projectEnd}}</span>
        </el-form-item>
        <el-form-item label="资金来源" prop="projectSource">
          <span class="int-text">{{showForm.projectSource}}</span>
        </el-form-item>
        <el-form-item label="建筑面积" prop="buildArea">
          <span class="int-text">{{showForm.buildArea}}</span>
        </el-form-item>
        <el-form-item label="意见" class="full" prop="remarks">
          <span class="int-text">{{showForm.remarks}}</span>
        </el-form-item>
      </el-form>
      <div class="card-title">代建单位信息</div>
      <el-form ref="editForm" :model="showForm" class="form-wrap" size="small" label-position="top">
        <el-form-item label="代建单位" prop="agentInfo">
          <span class="int-text">{{showForm.agentInfo}}</span>
        </el-form-item>
        <el-form-item label="单位联系人" prop="agentContact">
          <span class="int-text">{{showForm.agentContact}}</span>
        </el-form-item>
        <el-form-item label="联系电话" prop="agentPhone">
          <span class="int-text">{{showForm.agentPhone}}</span>
        </el-form-item>
      </el-form>
      <div class="card-title">代建单位中标通知书信息</div>
      <el-form ref="editForm" :model="showForm" class="form-wrap" size="small" label-position="top">
        <el-form-item label="中标通知书文号" prop="bidDocument">
          <span class="int-text">{{showForm.bidDocument}}</span>
        </el-form-item>
        <el-form-item label="金额(元)" prop="bidAmount">
          <span class="int-text">{{showForm.bidAmount}}</span>
        </el-form-item>
        <el-form-item label="审批日期" prop="bidApprove">
          <span class="int-text">{{showForm.bidApprove}}</span>
        </el-form-item>
      </el-form>
      <div class="card-title">关联物业信息</div>
      <div class="handling-opinions">
        <el-table :data="tableData">
          <el-table-column label="项目名称" prop="projectName" />
          <el-table-column label="物业名称" prop="propertyName" />
          <el-table-column label="建筑面积" prop="buildingArea" />
          <el-table-column label="套内面积" prop="unitConstructionArea" />
          <el-table-column label="物业类型" prop="projectType">
            <template slot-scope="scope">{{getCardTypeValue(scope.row.projectType,projectTypeList)}}</template>
          </el-table-column>
          <el-table-column label="物业用途" prop="projectSubclassType">
            <template slot-scope="scope">{{getCardTypeValue(scope.row.projectSubclassType,projectSubclassTypeList)}}</template>
          </el-table-column>
        </el-table>
      </div>
      <div class="card-title">附件</div>
      <div class="handling-opinions">
        <v-upload
          ref="registrationUpload"
          :busId="showForm.projectId"
          modelType="registration"
          isShowFileList
          :isView="true"
          multiple
          v-model="fileList"
        />
      </div>
      <span slot="foot">
        <el-button @click="lookOperationList">操作记录</el-button>
        <el-button type="primary" @click="shutDown">关闭</el-button>
      </span>
    </v-dialog>
  </div>
</template>

<script>
import { get } from '../api/registration'
export default {
  name: "show-actual",
  mounted () {
    this.projectTypes = this.getDict("epc_project_type")
    this.projectTypeList = this.getDict('property_types')
    this.projectSubclassTypeList = this.getDict('property_use_types')
  },
  data () {
    return {
      dialogVisible: false,
      fileList: [],
      projectTypes: [],
      tableData: [],
      projectTypeList: [],
      projectSubclassTypeList: [],
      showForm: {
        projectId: '',
        projectName: '',
        projectAddress: '',
        projectType: '',
        projectContent: '',
        projectScale: '',
        projectStart: '',
        projectEnd: '',
        projectSource: '',
        remarks: '',
        agentInfo: '',
        agentContact: '',
        agentPhone: '',
        bidDocument: '',
        bidAmount: '',
        bidApprove: '',
        buildArea: '',
        decorationArea: ''
      }
    }
  },
  methods: {
    // 查看操作记录
    lookOperationList () {
      this.$bus.$emit('operationLog', this.showForm.projectId)
    },
    //打开弹框
    show (item) {
      this.dialogVisible = true
      if (item) {
        this.showForm.projectId = item
        get(item).then(res => {
          if (res.data.code === 0) {
            this.showForm = res.data.data.epcProject
            this.tableData = res.data.data.rooms
          }
        })
      }
    },
    //关闭弹框
    beforeClose (done) {
      this.$emit('beforeClose')
    },
    shutDown () {
      this.$emit('handleClose')
      this.dialogVisible = false
    },
    //对应value取label
    getCardTypeValue (num, sum) {
      let arr = sum.filter(e => e.value === num)
      if (arr.length > 0) {
        return arr[0].label
      } else {
        return num
      }
    }
  }
}
</script>

<style scoped lang="scss">
.card-box {
  min-height: 55px;
  .handling-opinions {
    padding: 20px;
  }
  .int-text {
    color: #999;
  }
}
</style>
